package com.paperobot.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.paperobot.dao.BaseDao;
import com.paperobot.dao.NewsDao;
import com.paperobot.model.News;

@Repository("newsDao")
public class NewsDaoImpl extends BaseDao implements NewsDao{

	public Long addNews(News news) throws Exception {
		Object obj=	saveObject("addNews", news);
		if(null!=obj){
			return (Long)obj;
		}
		return -1L;
	}

	public News getNews(Long newsId) throws Exception {
		return (News) getObject("getNews", newsId);
	}

	@SuppressWarnings("unchecked")
	public List<News> getNewsList(Map<String, Object> map) throws Exception {
		return (List<News>) getObjects("getNewsList", map);
	}

	public int updateNews(News news) throws Exception {
		return updateObject("updateNews", news);
	}

	public int deleteNews(Long newsId) throws Exception {
		return deleteObject("deleteNews", newsId);
	}

	@SuppressWarnings("unchecked")
	public List<News> getHotNewsList(Map<String, Object> map) throws Exception {
		return (List<News>) getObjects("getHotNewsList", map);
	}

	@SuppressWarnings("unchecked")
	public List<News> getRecommendNewsList(Map<String, Object> map) throws Exception {
		return (List<News>) getObjects("getRecommendNewsList", map);
	}

	public int updateNewsClickNum(Long newsId) throws Exception {
		return updateObject("updateNewsClickNum", newsId);
	}

}
